package com.tulink.yichutu.controller.wxpay;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.util.List;
import com.tulink.yichutu.common.utils.DataResult;

import com.tulink.yichutu.entity.WxVipCashCouponEntity;
import com.tulink.yichutu.service.WxVipCashCouponService;



/**
 * 商品表
 *
 * @author wenbin
 * @email *****@mail.com
 * @date 2021-10-04 05:52:57
 */
@Controller
@RequestMapping("/")
public class WxVipCashCouponController {
    @Autowired
    private WxVipCashCouponService wxVipCashCouponService;


    /**
    * 跳转到页面
    */
    @GetMapping("/index/wxVipCashCoupon")
    public String wxVipCashCoupon() {
        return "wxvipcashcoupon/list";
        }

    @ApiOperation(value = "新增")
    @PostMapping("wxVipCashCoupon/add")
    @RequiresPermissions("wxVipCashCoupon:add")
    @ResponseBody
    public DataResult add(@RequestBody WxVipCashCouponEntity wxVipCashCoupon){
        wxVipCashCouponService.save(wxVipCashCoupon);
        return DataResult.success();
    }

    @ApiOperation(value = "删除")
    @DeleteMapping("wxVipCashCoupon/delete")
    @RequiresPermissions("wxVipCashCoupon:delete")
    @ResponseBody
    public DataResult delete(@RequestBody @ApiParam(value = "id集合") List<String> ids){
        wxVipCashCouponService.removeByIds(ids);
        return DataResult.success();
    }

    @ApiOperation(value = "查询分页数据")
    @PostMapping("wxVipCashCoupon/listByPage")
    @RequiresPermissions("wxVipCashCoupon:list")
    @ResponseBody
    public DataResult findListByPage(@RequestBody WxVipCashCouponEntity wxVipCashCoupon){
        Page page = new Page(wxVipCashCoupon.getPage(), wxVipCashCoupon.getLimit());
        LambdaQueryWrapper<WxVipCashCouponEntity> queryWrapper = Wrappers.lambdaQuery();
        //查询条件示例
        //queryWrapper.eq(WxVipCashCouponEntity::getId, wxVipCashCoupon.getId());
        IPage<WxVipCashCouponEntity> iPage = wxVipCashCouponService.page(page, queryWrapper);
        return DataResult.success(iPage);
    }

}
